package com.lhgray.sglhome.data.repository

import android.net.Uri
import com.freightoa.foundation.net.ApiResult
import com.freightoa.foundation.presentation.repository.BaseRepository
import com.lhgray.sglhome.data.network.api.HomeServer
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody.Companion.toRequestBody
import javax.inject.Inject

class MyAccountRepository @Inject constructor() : BaseRepository {
    @Inject
    lateinit var homeServer: HomeServer
    suspend fun uploadPic(list: MutableList<Uri>): Result<String> {

        return when (homeServer.uploadPic(
            description = HashMap(),
            file = MultipartBody.Part.createFormData(
                "file", "", "hello".toRequestBody("image/jpg".toMediaTypeOrNull())
            )
        )) {
            is ApiResult.Success -> {
                Result.success("")
            }

            is ApiResult.Error -> {
                Result.failure(RuntimeException("13"))
            }

            is ApiResult.Exception -> {
                Result.failure(RuntimeException("13"))
            }
        }
    }


}